//
//  DemoLabel.swift
//  one
//
//  Created by huangfeng on 2018/5/6.
//  Copyright © 2018年 huangfeng. All rights reserved.
//

import UIKit

class DemoLabel: UILabel {

    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */
    //纯代码 调用时会走这个方法
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    
    
    //通过xib 创建时会调用
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        
        setupUI()
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI() {
        print("加载UI")
    }
    
    
    // 通过这种方式 设置 模型
    var person: LPerson? {
        didSet {
            text = person?.name
        }
    }
    
}
